﻿using AspDotNet.Core7.First.Services;

namespace AspDotNet.Core7.First.Middlewares
{
    public class RequestEditingMiddleware
    {
        private RequestDelegate NextMiddleware { get; set; }
        public RequestEditingMiddleware(RequestDelegate nextMiddleware)
        {
            NextMiddleware = nextMiddleware;
        }

        public async Task Invoke(HttpContext httpContext)
        {
            httpContext.Items["Firefox"] = httpContext.Request.Headers["User-Agent"].Any(v => v.Contains("Firefox"));
            await NextMiddleware.Invoke(httpContext);
        }
    }
}
